[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
eof() Test for End of File
#include <io.h>
int eof(handle);
int handle; Handle referring to open file
eof() checks the file associated with 'handle' to find out whether
end-of-file has been reached.
Returns: 1 End of file reached
0 Current position is not end of file
-1 An error occurred.
On error, 'errno' is set to:
EBADF: a bad file handle.
-------------------------------- Example ---------------------------------
The following statements open a file for reading then count the
number of bytes read until end of file is reached.
#include <io.h>
#include <fcntl.h>
int fhndl, count, totalbytes;
char buff[1000];
main()
{
fhndl = open("data",O_RDONLY);
totalbytes = 0;
while (!eof(fhndl)) {
count = read(fhndl, buff, 10);
totalbytes += count;
}
}
See Also:
clearerr()
feof()
ferror()
perror()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson